package com.daiyang.blog.common.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AppConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/user/**", "/blog/**") // 这个是拦截对应的请求接口，/user/login这个接口也被拦截了
                 .excludePathPatterns("/user/login", "/user/register", "/user/logout") //放行登录，注册，注销登录接口
        ;
    }
}
